import { Outlet, useNavigate } from "react-router-dom";
import MyNav from "../components/MyNav";
import { useEffect } from "react";
import userStore from "../stores/UserStore";
import { observer } from "mobx-react-lite";

function Layout02(){
    let navigator = useNavigate();
    let user = userStore.getUser();
    
    useEffect(()=>{
        if(!sessionStorage.getItem('token')){
            alert("请先登录");
            navigator("/login");
        }
    },[navigator,user])
    
    if(!sessionStorage.getItem('token'))
        return null;
    return(
        <div>
            <MyNav/>
            <Outlet />
        </div>
    )
}

export default observer(Layout02);